<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;

class CreateAccessTokensTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('access_tokens', function (Blueprint $table) {
            $table->id();
            $table->integer('store_id')->unsigned()->comment('店铺id');
            $table->string('access_token', 600)->comment('access_token');
            $table->datetime('expire_at')->comment('access_token过期时间');
            $table->string('ticket', 600)->default('')->comment('公众号用于调用微信JS接口的临时票据');
            $table->datetime('ticket_expire_at')->nullable()->comment('ticket过期时间');
            $table->timestamps();
        });

        DB::statement("ALTER TABLE `access_tokens` comment '微信access_token表'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('access_tokens');
    }
}
